
$(function(){
    listarAnio('ddanio','Todos');
    listarSede('ddsede','Todos');
    $("#btnBuscarMulta").click(function(){
        buscar();
    });
    buscar();
});

var buscar = function() {

    var vid_multa = $("#txtMultaSearch").val();
    var vanio = $("#ddanio").val();
    var vid_sede = $("#ddsede").val();
    var vurli='ajax/ajaxCUM.php?opc=bus&nd='+new Date().getTime()+'&id_multa='+vid_multa+'&vanio='+vanio+'&sede='+vid_sede;
    
    var cum = {
        opc:"bus",
        id_multa: $("#txtMultaSearch").val(),
        anio: $("#ddanio").val(),
        id_sede: $("#ddsede").val()
    };
    $("#grid").jqGrid("clearGridData", true);
    $("#grid").jqGrid('setGridParam',{url:vurli,datatype:'json',mtype: 'POST',postData:cum}).trigger('reloadGrid');
    
    jQuery("#grid").jqGrid({
        url:vurli,
        datatype: "json",
        mtype: 'POST',
        postData:cum,
        colNames: ['Multa','A&#241;o', 'Codigo Sede','Sede','File Asociado','A&#241;o File','Fecha de Registro'],
        colModel: [
                    {name: 'ID_MULTA',index: 'ID_MULTA',width: 100,sorttype:"string"},
                    {name: 'ANIO',index: 'ANIO',width: 100,sorttype:"string"},
                    {name: 'ID_SEDE',index: 'ID_SEDE',width: 100,sorttype:"string",hidden:true},
                    {name: 'SEDE',index: 'SEDE',width: 100,sorttype:"string"},
                    {name: 'NRO_FILE_AEC',index: 'NRO_FILE_AEC',width: 100,sorttype:"string"},
                    {name: 'ANIO_FILE_AEC',index: 'ANIO_FILE_AEC',width: 100,sorttype:"string"},
                    {name: 'AUDFECCREACION',index: 'AUDFECCREACION',width: 100,sorttype:"string"}
                  ],
        rowNum:10,
   	rowList:[10,20,30],
   	pager: '#pager',
   	sortname: 'id',
        viewrecords: true,
        sortorder: "desc",
        multiselect: true,
        multiSort:true,
        width: "800",
        height: "220",
        caption: "Multas"
    }).navGrid("#pager", {
        edit: false,
        add: false,
        search: false,
        del: false
    });
    
    
};

jQuery.extend(jQuery.jgrid.edit, {
    ajaxEditOptions: { contentType: "application/json" },
    recreateForm: true,
    serializeEditData: function (postData) {
        return JSON.stringify(postData);
    }
});

jQuery.extend(jQuery.jgrid.del, {
    ajaxDelOptions: { contentType: "application/json" },
    serializeDelData: function (postData) {
        return JSON.stringify(postData);
    }
});